/*
 * 本文件定义各种身份的路径访问权限
 * 以供外部使用
 **/

import { defineStore } from 'pinia';

export const usePathPermissionStore = defineStore('path-permission', {

  state: () => ({

    // 无用户信息时允许访问的路径
    publicPaths: [

      '/login',
      '/register',
      '/front',

    ] as string[],

    // 不允许访问的路径
    permissionRules: {

      USER: [
        '/announcement',
        '/package',
      ],

      MANAGER: [
      ],

    } as Record<string, string[]>,
  }),

  getters: {

    getForbiddenPaths: (state) => (role: string) => {
      return state.permissionRules[role] || [];
    },

    getPublicPaths: (state) => state.publicPaths,
  },
});